package com.xuelang.pipeline.artifact.client.common.vo;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xiwen.zxg
 * @since 2024/5/30
 */
@Data
@Configuration
@ConfigurationProperties("pipeline")
public class PipelineProperties {

    /**
     * 集群Worker配置
     */
    private Worker worker = new Worker();
    /**
     * 仓库配置
     */
    private Artifact artifact = new Artifact();
    /**
     * 授权配置
     */
    @Data
    public static class Authorization {
        /**
         * harbor
         */
        private String harbor;
        /**
         * nexus3
         */
        private String nexus3;
    }

    /**
     * 仓库配置
     */
    @Data
    public static class Artifact {
        /**
         * 仓库类型
         */
        private String mavenUrlPrefix = "localhost:18081/repository/";
        /**
         * 仓库类型
         */
        private String npmUrlPrefix = "http://localhost:18081/repository/";
        /**
         * 仓库类型
         */
        private String genericUrlPrefix = "http://localhost:18081/repository/";
        /**
         * 仓库类型
         */
        private String dockerUrlPrefix = "http://localhost:18081/repository/";
        /**
         * 授权配置
         */
        private Authorization authorization = new Authorization();
    }

    /**
     * 集群Worker配置
     */
    @Data
    public static class Cluster {
        /**
         * 集群名称
         */
        private String name;
        /**
         * 集群uuid
         */
        private String uuid;
        /**
         * 集群对应worker访问地址
         */
        private String workerUrl;
        /**
         * 集群对应worker状态
         */
        private String workerStatus;

    }

    /**
     * worker配置
     */
    @Data
    public static class Worker {
        private List<Cluster> clusters = new ArrayList<>();
    }

}
